package com.example.springboot.controller;

import com.example.springboot.exception.PasswordException;
import com.example.springboot.exception.ValidateCodeException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Description: GoodsController
 * @Author wenlinyu
 * @Date: 2020/12/16 15:04
 * @Version 1.0
 */
@Controller
public class GoodsController {

    @GetMapping("/goods")
    public String goods() {
        return "goods";
    }

    @GetMapping("/checkPassword")
    public String checkPassword() throws PasswordException {
        if (true) {
            // 抛出异常，便于测试
            throw new PasswordException();
        }
        return "goods";
    }

    @GetMapping("/checkValidate")
    public String checkValidate() throws ValidateCodeException {
        if (true) {
            // 抛出异常，便于测试
            throw new ValidateCodeException();
        }
        return "goods";
    }

    @GetMapping("/other")
    public String other() throws Exception {
        // 模拟异常
        int a = 1 / 0;
        return "goods";
    }
}
